<template>
    <el-menu class="nav-menu" router text-color="#444" style="width: 200px" active-text-color="#409EFF">
        <el-submenu v-for="(item,menuIndex) in menuData" :index="menuIndex+''" v-if="(item.roles!=null && item.roles.indexOf(role)!==-1) || role === 100">
            <template slot="title">{{item.title}}</template>
            <el-menu-item v-for="children in item.childrens" :index="children.link" v-if="(children.roles!=null && children.roles.indexOf(role)!==-1) || role === 100">{{children.name}}</el-menu-item>
        </el-submenu>
    </el-menu>
</template>
<script>
    import {mapMutations, mapGetters} from 'vuex'
    //需要导入vuex的数据管理
    import Store from '../../store/index.js'

    export default {
        components: {},
        computed: {
            ...mapGetters(['hasPerm', 'hasPerms'])
        },
        created() {
            this.$root.eventHub.$on('closePassEditDialog', this.hidePassDialog);
            this.role = Store.state.user.role;
        },
        beforeDestroy: function () {
            this.$root.eventHub.$off('closePassEditDialog', this.hidePassDialog);
        },
        methods: {
            ...mapMutations([
                'clearUser'
            ])
        },
        data() {
            return {
                isShowPassEditDialog: false,
                role: '',
                menuData: [
                    {
                        title: '首页',
                        childrens: [
                            {
                                name: '数据统计',
                                link: '/'
                            },
                            {
                                name: '流量图',
                                link: '/visitNum'
                            },
                            {
                                name: '积分流水',
                                link: '/integral'
                            }
                        ]
                    },
                    {
                        roles: [1, 2 , 3],
                        title: '采购中心',
                        childrens: [
                            {
                                roles: [1, 2 , 3],
                                name: '采购列表',
                                link: '/procurement'
                            },
                            {
                                name: '推送记录',
                                link: '/procurement/pushList'
                            }
                        ]
                    },
                    {
                        roles: [1, 2 , 3],
                        title: '项目合作',
                        childrens: [
                            {
                                roles: [1, 2 , 3],
                                name: '项目列表',
                                link: '/project'
                            }
                        ]
                    },
                    {
                        roles: [1, 2 , 3],
                        title: '招聘管理',
                        childrens: [
                            {
                                roles: [1, 2 , 3],
                                name: '招聘列表',
                                link: '/job'
                            }
                        ]
                    },
                    {
                        roles: [1, 2 , 3],
                        title: '线下活动',
                        childrens: [
                            {
                                roles: [1, 2 , 3],
                                name: '活动列表',
                                link: '/activity'
                            },
                            {
                                roles: [2 , 3],
                                name: '推荐配置',
                                link: '/activityRecommendList'
                            }
                        ]
                    },
                    {
                        roles: [1, 2 , 3],
                        title: '风采管理',
                        childrens: [
                            {
                                roles: [1, 2 , 3],
                                name: '个人风采',
                                link: '/news/listOfMember'
                            }
                        ]
                    },
                    {
                        roles: [2],
                        title: '商铺管理',
                        childrens: [
                            {
                                roles: [2],
                                name: '商品列表',
                                link: '/product'
                            },
                            {
                                roles: [2],
                                name: '退款列表',
                                link: '/refundOrder'
                            }
                        ]
                    },
                    {
                        roles: [10],
                        title: '工厂管理',
                        childrens: [
                            {
                                roles: [10],
                                name: '工厂认证列表',
                                link: '/company/authList'
                            }
                        ]
                    },
                    {
                        roles: [1, 2 , 3],
                        title: '会员管理',
                        childrens: [
                            {
                                roles: [1, 2,3],
                                name: '所有用户',
                                link: '/allMember'
                            },
                            {
                                roles: [1, 2, 3],
                                name: '游客列表',
                                link: '/visitor'
                            },
                            {
                                roles: [1, 2 , 3],
                                name: '商务列表',
                                link: '/member'
                            },
                            {
                                roles: [ 2 , 3],
                                name: '企业列表',
                                link: '/store'
                            },
                            {
                                roles: [ 2 , 3],
                                name: '商协会列表',
                                link: '/commerce'
                            },
                            {
                                roles: [3],
                                name: '超级公司申请',
                                link: '/superCompany'
                            },
                            {
                                name: 'App管理者列表',
                                link: '/superman'
                            }
                        ]
                    },
                    {
                        roles: [3],
                        title: '积分管理',
                        childrens: [
                            {
                                roles: [3],
                                name: '积分列表',
                                link: '/commission'
                            },
                            {
                                name: '提现列表',
                                link: '/drawCash'
                            }
                        ]
                    },
                    {
                        title: '子账号',
                        childrens: [
                            {
                                name: '子账号管理',
                                link: '/account/SubordinateAccount'
                            }
                        ]
                    },
                    {
                        title: '活动赠送',
                        childrens: [
                            {
                                name: '即时通赠送',
                                link: '/jishitong'
                            }
                        ]
                    },
                    {
                        roles: [3],
                        title: '系统配置',
                        childrens: [
                            {
                                name: '订单配置',
                                link: '/systemConfig/OrderConfig'
                            },
                            {
                                roles: [3],
                                name: '投诉',
                                link: '/systemConfig/complain'
                            }
                        ]
                    }
                ]
            }
        }
    }
</script>

<style type="text/css">

</style>
